import { createRouter, createWebHistory } from 'vue-router'
import UserAuth from '../views/user/auth/UserAuth.vue'
import AdminLogin from "@/views/admin/AdminLogin.vue";
import marketOverview from "@/views/market/MarketOverview.vue";
import findStock from "@/views/market/stock/FindStock.vue";
import TheMain from "@/views/market/MarketMain.vue";
import UserRegister from "@/views/user/auth/UserRegister"
import AdminForStock from "@/views/admin/AdminForStock"
import AdminForUser from "@/views/admin/AdminForUser"
import AdminLayout from "@/views/admin/AdminLayout"
import EmailVerification from "@/views/user/auth/EmailVerification.vue"
import UserInfo from "@/views/user/account/UserInfo.vue"
import StockNumAndSymbol from "@/views/market/stock/StockNumAndSymbol.vue"
import StockInformation from "@/views/market/stock/StockInformation";
import AboutUs from "@/views/welcome/AboutUs.vue";
import UserStars from "@/views/user/account/UserStars.vue"
import UserPortfolio from "@/views/user/account/UserPortfolio.vue"
import UserOrder from "@/views/user/account/UserOrder.vue"
import SearchStock from "@/views/market/SearchStock.vue"
import UsersPositions from "@/views/user/account/userStock/UsersPositions.vue"
import UserBuyStock from "@/views/user/account/userStock/UserBuyStock.vue"
import UserSellStock from "@/views/user/account/userStock/UserSellStock.vue"
import HelpUser from "@/views/welcome/HelpUser";
const routes = [
  {
    path: '/',
    redirect: '/center/welcome'  // 添加重定向
  },

 //管理员登录
  {
    path: '/adminLogin',
    name: 'AdminLogin',
    component: AdminLogin
  },
    //管理员主框架
  {
    path: '/adminLayout',
    name: 'AdminLayout',
    component: AdminLayout,
    redirect: '/admin/user',
    children: [
      {
        path: '/admin/user',
        name: 'AdminUser',
        component: AdminForUser
      },
      {
        path: '/admin/stock',
        name: 'AdminStock',
        component: AdminForStock
      },
    ]
  },

    //用户使用主要框架
  {
    path: '/center',
    name:'TheMain',
    component: TheMain,
    redirect:'/center/welcome',

    children:[
      {
        path: 'welcome',
        name: 'Welcome',
        component: () => import('@/views/welcome/WelcomePage.vue'),
      },
      {
        path: 'aboutUs',
        name: 'aboutUs',
        component:AboutUs
      },
      {
        path: 'stockNumAndSymbols',
        name: 'stockNumAndSymbols',
        component: StockNumAndSymbol
      },
      {
        path: 'stockInformation',
        name: 'stockInformation',
        component: StockInformation
      },
      {
        path: 'findStock',
        name:'findStock',
        component: findStock,
        redirect:'/center/findStock/marketOverview',
        children:[{
          path: 'marketOverview',
          name:'marketOverview',
          component:marketOverview
        }
        ]
      },
      {
        path: '/user/auth',
        name: 'UserAuth',
        component: UserAuth,
        meta: { hideFooter: true }
      },
      {
        path: '/user/register',
        name: 'UserRegister',
        component: UserRegister,
        meta: { hideFooter: true }
      },
      {
        path: '/user/email-verification',
        name: 'EmailVerification',
        component: EmailVerification,
        meta: { hideFooter: true }
      },
      {
        path: '/account/profile',
        name: 'AccountProfile',
        component: UserInfo,
      },
      {
        path: '/user/userStars',
        name: 'UserStar',
        component: UserStars
      },
      {
        path: '/user/portfolio',
        name: 'UserPortfolio',
        component: UserPortfolio
      },
      {
        path: '/user/order',
        name: 'UserOrder',
        component: UserOrder
      },
      {
        path:'/findStock/searchStock',
        name: 'searchStock',
        component: SearchStock
      },
      {
        path: '/user/usersPositions',
        name: 'UsersPositions',
        component: UsersPositions
      },
      {
        path: '/user/userSellStock',
        component: UserSellStock
      },
      {
        path: '/user/userBuyStock',
        component: UserBuyStock
      },
      {
        path: '/center/helpUser',
        component: HelpUser
      },

      {
        path: 'about',
        name: 'AboutUs',
        component: AboutUs
      }



    ]
    

  }

]

//创建路由器
const router = createRouter({
  history: createWebHistory(),
  routes: routes
})

export default router